﻿using System.Text;
using System.Threading.Tasks;
using Mammoth.Entities;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace Mammoth.Mappings
{
    public class AccountEntityMapping : EntityMapping<AccountEntity>
    {
        public const int EmailLength = 256;
        public const int NameLength = 128;

        public AccountEntityMapping()
        {
            Table("tabel_account");
            Property(x => x.Email, m => m.Length(EmailLength));
            Property(x => x.Name, m => m.Length(NameLength));
            Bag<OutboxEntity>(x => x.Outbox,
                p =>
                {
                    p.Key(k => k.Column(c => c.Name("AccountId")));
                },
                r => r.OneToMany());
            Bag<InboxEntity>(x => x.Inbox,
                p =>
                {
                    p.Key(k => k.Column(c => c.Name("AccountId")));
                },
                r => r.OneToMany());
        }
    }
}
